//package com.example.demo.service;
//
//import com.example.demo.entity.Users;
//import com.example.demo.mapper.UsersMapper;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.util.HashMap;
//import java.util.Map;
//
//@Service
//public class UsersService {
//    @Autowired
//    private UsersMapper usersMapper;
//
//    public Users getClassByUsername(String username){
//        return usersMapper.getClassByUsername(username);
//    }
//
//    public Users getIdByUsername(String username){
//        return usersMapper.getIdByUsername(username);
//    }
//
//    public Users getIdByPhoneNumber(String phoneNumber){
//        return usersMapper.getIdByPhoneNumber(phoneNumber);
//    }
//
//    public boolean login(String username, String password) {
//        Users users = usersMapper.getByUsername(username);
//        if (users != null && users.getPassword().equals(password)) {
//            return true;
//        }
//        return false;
//    }
//
//
//}

package com.example.demo.service;
import com.example.demo.entity.Users;
import com.example.demo.mapper.UsersMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class UsersService {

    @Autowired
    private UsersMapper usersMapper;

    @Autowired
    private RedisTemplate<String, String> redisTemplate; // 假设你已经配置好了RedisTemplate

    public Users getClassByUsername(String username){
        return usersMapper.getClassByUsername(username);
    }

    public Users getIdByUsername(String username){
        return usersMapper.getIdByUsername(username);
    }

    public Users getIdByPhoneNumber(String phoneNumber){
        return usersMapper.getIdByPhoneNumber(phoneNumber);
    }

    public boolean login(String username, String password) {
        Users users = usersMapper.getByUsername(username);
        if (users != null && users.getPassword().equals(password)) {
            return true;
        }
        return false;
    }


}
